package com.dailyblue.project.smbms.alibaba.login.handler;

import com.dailyblue.project.smbms.alibaba.commons.util.JsonResult;
import com.dailyblue.project.smbms.alibaba.commons.util.ResultCode;
import com.dailyblue.project.smbms.alibaba.commons.util.ResultTool;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = UserNameNotFoundHandler.class)
    public JsonResult userNameNotFound() {
        return ResultTool.fail(ResultCode.USER_ACCOUNT_NOT_EXIST);
    }

    @ExceptionHandler(value = PasswordErrorHandler.class)
    public JsonResult passwordError() {
        return ResultTool.fail(ResultCode.USER_CREDENTIALS_ERROR);
    }
}
